(function() {
	'use strict';
	angular.module('services.workOrderData.auditData')
		.factory('passRateService', passRateService);
	function passRateService(Restangular,CoreService){
		return {
			passRateQuery: passRateQuery,
			fmtSendData: fmtSendData,
			fmtDateTitle: fmtDateTitle
		};
		//请求方法
		function passRateQuery(params,callback){
			Restangular.all('sas/workOrderData/auditData/query').post(params).then(callback);
		}
		//格式化需求发送给后端的字段
	    function fmtSendData(sendData){
	      var send = {
	        startTime:'',
	        endTime: '',
	        workOrderTypeCode:'',
	        changeTypeCode: ''
	      };
	      send.startTime = CoreService.dateFormat(sendData.startTime, 'yyyy-MM');
	      send.endTime = CoreService.dateFormat(sendData.endTime, 'yyyy-MM');
	      send.workOrderTypeCode = sendData.workOrderTypeCode;
	      send.changeTypeCode = sendData.changeTypeCode;
	      send.timeType = sendData.timeType;
	      return send;
	    }
	    function fmtDateTitle(send){
	      var timeTitle = '';
	      var startYear = send.startTime.substring(0, 4)+'年';
	      var endYear = send.endTime.substring(0, 4)+'年';
	      var startMonth = send.startTime.substring(5, 7)+'月';
	      var endMonth = send.endTime.substring(5, 7)+'月';
	      var booleanYear = startYear === endYear;
	      var booleanMonth = startMonth === endMonth;
		  timeTitle = booleanYear && booleanMonth ? startYear + startMonth : startYear + startMonth + ' 至 ' + endYear + endMonth;   
	      return timeTitle;
	    }	
 }	
})();